/**
 * @summary 查询模块
 * @description 7.25新增全部频道数据
 * @author xxx
 */

import { getSuggestionList, getSearchResult } from "@/api/search";

export default {
  // 我是模块
  namespaced: true,
  state: {
    suggestionList: [],
    searchResult: [],
  },
  mutations: {
    SET_SUGGESTION_LIST(state, newValue) {
      state.suggestionList = newValue;
    },
    SET_SEARCH(state, newValue) {
      state.searchResult = newValue;
    },
  },
  actions: {
    async updateSuggestionList({ commit }, searchValue) {
      // 发请求
      // 拿到数据
      const res = await getSuggestionList(searchValue);
      // 把数据传给mutation
      // mutation改数据
      commit('SET_SUGGESTION_LIST', res)
    },
    // async updateChannelList({commit}}) {
    //   // 发请求
    //   // 拿到数据
    //   const res = await getChannelList();
    //   // 把数据传给mutation
    //   // mutation改数据
    //   commit('SET_CHANNEL_LIST', res)
    // },
    async updateSearchReault({ commit }, searchValue) {
      const res = await getSearchResult(searchValue);
      commit('SET_SEARCH', res)
    }
  },

}
